package cn.xydream.order;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.Bean;
import org.springframework.web.client.RestTemplate;

// @EnableFeignClients(defaultConfiguration = DefaultFeignConfiguration .class) // 基于Java代码来修改日志级别 全局生效
// @EnableFeignClients() // 开启Feign
@EnableFeignClients(basePackages = "com.xydream.feign.clients")
@MapperScan("cn.xydream.order.mapper")
@SpringBootApplication
public class OrderApplication {

    public static void main(String[] args) {
        SpringApplication.run(OrderApplication.class, args);
    }

    /**
     * 创建RestTemplate
     * @return
     */
    @Bean
    @LoadBalanced
    public RestTemplate restTemplate() {
        return new RestTemplate();
    }

    /**
     * 键负载均衡设置为随机
     * Nacos配置了负载均衡设ribbon需要注释改行代码
     * @return
     */
//    @Bean
//    public IRule randomRule() {
//        return new RandomRule();
//    }
}
